package cn.wgx.modules.sys.web;

import cn.wgx.modules.base.web.BaseController;
import cn.wgx.modules.sys.services.SysChinaCityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


@Api(tags = "8. 获取城市区域")
@RestController
@RequestMapping(value="${allPathPre}city")
public class SysChinaCityController extends BaseController {
    @Resource
    SysChinaCityService sysChinaCityService;


    @ApiOperation("默认为获取全国省份名单,通过省份的codeid获取下级地区,返回{'success':true,'res':[{},{}]}")
    @RequestMapping(path = "", method = RequestMethod.GET)
    public Map<String,Object> getList(@RequestParam(value = "parentid" ,defaultValue = "0", required = false) Integer parentid) {
        return returnData(sysChinaCityService.getList(parentid));
    }

    @ApiOperation("根据ID获取城市")
    @RequestMapping(path = "get/{id}", method = RequestMethod.GET)
    public Map<String,Object> getCityById(@PathVariable(value = "id") Integer id) {
        return returnData(sysChinaCityService.getOne(id));
    }


}